﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;

/// <summary>
/// Summary description for ImageCell
/// </summary>
public class ImageCell
{
    private string m_szImagePath;
    private Rectangle m_BoundingRect;
    private Bitmap m_pImage;

    public ImageCell(string szImagePath, Rectangle boundingRect)
    {
	    m_szImagePath = szImagePath;
	    m_BoundingRect = boundingRect;
	    m_pImage = null;
    }

    public void Draw(Graphics g)
    {
	    if(m_pImage != null)
	    {
		    ImageAttributes ia = new ImageAttributes();
		    ia.SetWrapMode(WrapMode.TileFlipXY);
		    g.DrawImage(m_pImage, m_BoundingRect, 0, 0, m_pImage.Width, m_pImage.Height, GraphicsUnit.Pixel, ia);
	    }
    }

    public void Load(string lpszFilePath)
    {
	    m_pImage = new Bitmap(lpszFilePath);
    }

    public void Load(Stream stream)
    {
        m_pImage = new Bitmap(stream);
    }
}